<template>
  <div class="app">
    <router-view></router-view>
  </div>
</template>

<script>
import Storage from './Storage'
export default {
  name: 'App',
  methods: {
    // 监听到页面的刷新后将vuex中的数据储存到浏览器中
    refush() {
      // const { userInfo } = this.$store.state
      // const { shopCatList } = this.$store.state
      // const { userAddress } = this.$store.state
      // Storage.setItem('state', { userInfo, shopCatList, userAddress })
      Storage.setItem('state', this.$store.state)
    }
  },
  mounted() {
    window.addEventListener('beforeunload', () => {
      this.refush()
    })
    // 页面挂载后获取储存到本地中的vuex数据
    const state = Storage.getItem('state')
    this.$store.commit('LOADING', state)
  }
}
</script>

<style lang=scss>
/* 对于静态样式直接引入即可 */
@import './assets/scss/reset.scss';
</style>
